﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "UniIdentity.h"
#include "GmQtGuiImplementation.h"
#include "ICategoryAndGraphicsStyleFilter.h"

class GM_QT_GUI_IMPLEMENTATION_EXPORT GmGraphicsStyleFilter : public gcmp::ICategoryAndGraphicsStyleFilter
{
public:
    GmGraphicsStyleFilter();
    virtual ~GmGraphicsStyleFilter();

public:
    virtual bool InitializeBuiltInCategoriesForProject(gcmp::ICategoryLibrary* pCategoryLibrary) const override;
    virtual bool InitializeGraphicsStyleAndGraphicsMaterialOfBuiltInCategoriesForProject(gcmp::IDocument* pDoc)const override;
    virtual bool InitializeBuiltInCategoriesForFamily(gcmp::ICategoryLibrary* pCategoryLibrary) const override;
    virtual bool InitializeGraphicsStyleAndGraphicsMaterialOfBuiltInCategoriesForFamily(gcmp::IDocument* pDoc)const override;

    // 用于“文档级对象样式设置”功能
    virtual std::vector<gcmp::UniIdentity> GetCategoriesForObjectStyleSetting(const gcmp::IDocument* pDoc) const override;
    virtual std::wstring GetObjectStyleSettingGroupForCategory(const gcmp::UniIdentity& cateogryUid, bool isFamilyDoc = false) const override;
    virtual std::vector<std::wstring> GetAllObjectStyleSettingGroups(bool isFamilyDoc = false) const override;
    // 返回使用的分组类别
    virtual gcmp::UniIdentity GetVisibiltyFilterGroupRelatedCategory(const std::wstring& strGroupName)const override;

    virtual bool ShowImportedCategoryGroupForObjectStyleSetting() const override { return true; }
    virtual std::vector<gcmp::UniIdentity> GetInternalCategoriesForObjectStyleSetting(const gcmp::IDocument* pDocument) const override;

    // 用于“文档级可见性过滤”功能
    virtual std::vector<gcmp::UniIdentity> GetCategoriesForVisibilityFilter(const gcmp::IDocument* pDoc) const override;
    virtual std::wstring GetVisibilityFilterGroupForCategory(const gcmp::UniIdentity& cateogryUid) const override;
    virtual std::vector<std::wstring> GetAllVisibilityFilterGroups() const override;

    // 用于“文档级拾取过滤”功能
    virtual std::vector<std::pair<gcmp::UniIdentity, bool>> GetCategoriesForSelectionFilter(const gcmp::IDocument* pDoc, bool isFamilyDoc = false) const override;

    // 判断一个类别是否可被平面视图剖切平面剖切
    virtual bool IsCuttableCategoryByPlanViewCutPlane(const gcmp::UniIdentity& categoryUid) const final;

    // 判断一个元素是否可被平面视图剖切平面剖切
    virtual bool IsCuttableElementByPlanViewCutPlane(const gcmp::IElement* pElement) const final;
private:
    std::vector<gcmp::UniIdentity> InitDefaultCategory(const gcmp::IDocument* pDocument, const std::set<gcmp::UniIdentity>& srcCategories) const;

private:
    std::set<gcmp::UniIdentity>  m_projectCategories;
    std::set<gcmp::UniIdentity>  m_geolabCategories;

    std::set<gcmp::UniIdentity>  m_familyEditorCategories;
    std::set<gcmp::UniIdentity>  m_structuralDetailingCategoriesExcluded;
};
